<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Order extends Model
{
    protected $guarded=[];

    public function orderList(){
        return $this->hasMany(OrderList::class,'order_id','id');
    }

    public function address(){
        return $this->belongsTo(Address::class,'address_id','id');
    }

    public function getOrderNumByStatus($status){
        return Order::where('user_id',auth()->id())->where('status',$status)->count();
    }
}
